package com.example.mountainwalker.controller;


import com.example.mountainwalker.entity.GroupTourRegistrationInfo;
import com.example.mountainwalker.entity.StrategyCommentInfo;
import com.example.mountainwalker.entity.TravelStrategyInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/sct")

public class StrategyCommentController {
    @Autowired
    private com.example.mountainwalker.service.StrategyCommentService strategyCommentService;

    //http://localhost:8080/sct/list
    @GetMapping("/list")
    public List<StrategyCommentInfo> getStrategyCommentList() {
        List<StrategyCommentInfo> strategyCommentInfo = strategyCommentService.getStrategyCommentInfo();
        return strategyCommentInfo;
    }

    // http://localhost:8080/sct/find/1
    @GetMapping("/find/{StrategyCommentID}")
    public StrategyCommentInfo getStrategyCommentById(@PathVariable Integer StrategyCommentID){
        StrategyCommentInfo strategyCommentInfo = strategyCommentService.getStrategyCommentInfoById(StrategyCommentID);
        return strategyCommentInfo;
    }

    // http://localhost:8080/sct/delete/1
    @DeleteMapping("/delete/{StrategyCommentID}")
    public int deleteStrategyCommentById(@PathVariable("StrategyCommentID") Integer StrategyCommentID) {
        int result = strategyCommentService.deleteStrategyCommentInfoById(StrategyCommentID);
        System.out.println("删除结果：" + result);  // 添加日志
        return result;
    }

    // http://localhost:8080/sct/insert
    @PostMapping("/insert")
    public int insertStrategyCommentInfo(@RequestBody StrategyCommentInfo strategyCommentInfo) {
        System.out.println("接受到的数据:"+strategyCommentInfo);
        int result = strategyCommentService.insertStrategyCommentInfo(strategyCommentInfo);
        return result;
    }

    //http://localhost:8080/sct/update
    @PutMapping("/update")
    public int updateStrategyCommentInfo(@RequestBody StrategyCommentInfo strategyCommentInfo){
        int result= strategyCommentService.updateStrategyCommentInfo(strategyCommentInfo);
        return result;
    }


}
